package com.ice.delay.task.core.constant;

import com.ice.framework.common.constant.IResultCode;

/**
 * @author wangwei
 * @Date 2021/12/20 15:14
 */
public enum ServerErrorCode implements IResultCode {
    SUCCESS("0", "成功"),
    PARAM_ERROR("10", "参数错误"),
    ERROR("11", "系统繁忙，请稍后重试"),
    TOKEN_CHECKFALSE("12", "Token无效或已过期,需重新获取"),
    PARAMETER_ERROR("13", "请求参数校验错误，请检查入参是否正确"),
    SQL_EXCEPTION("24", "SQL访问异常！"),
    USER_CERTIFICATION("25", "用户未认证"),

    USER_NOT_FOUND("10010", "用户不存在"),
    LOGIN_PASSWORD_NOT_CORRET("10011", "用户密码不正确"),
    ACCOUNT_CODE_EXISTS("10012", "账号已存在"),
    SYSTEM_USER_NOT_DELETED("10013", "系统默认用户无法删除"),

    MODULE_CODE_EXISTS("100009", "模块编码已存在"),
    ERR_DELAY_MODULE_NOT_FOUND("100010", "延迟模块未找到"),
    MODULE_ENABLED_NOT_CORRECT("100011", "模块状态不确定"),

    TASK_NOT_FOUND("100021", "任务不存在"),
    TASK_NOTIFY_STATUS_NOT_CORRECT("100022", "任务状态不正确"),
    ;

    private String code;
    private String message;

    private ServerErrorCode(String message) {
        this.message = message;
    }

    private ServerErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getCode() {
        return this.code == null ? this.name().substring(1) : this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }

    public boolean equals(String errorCode) {
        return this.code.equals(errorCode);
    }
}
